//
//  JingXuan_FenLei_ViewController.m
//  iBook
//
//  Created by apple on 15/1/19.
//  Copyright (c) 2015年 wikiflyer. All rights reserved.
//

#import "JingXuan_FenLei_ViewController.h"
#import "ShuJiXiangQing_ViewController.h"

@interface JingXuan_FenLei_ViewController ()

@end

@implementation JingXuan_FenLei_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    [_myTableV setTableFooterView:view];
    [_myTableV setBackgroundColor:[UIColor whiteColor]];
    [self.view addSubview:_myTableV];
    
    
    
    [self goLine];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _arrayDatas.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString * str1=@"123";
    JingXuan_FenLei_TableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:str1];
    if (!cell) {
        cell=[JingXuan_FenLei_TableViewCell homeCellCellOwner:self];
    }
    [cell initWithSome:_arrayDatas[indexPath.row]];
    return cell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 82;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    ShuJiXiangQing_ViewController * shujiV=[[ShuJiXiangQing_ViewController alloc] init];
    shujiV.strIDJieShou=[NSString stringWithFormat:@"%@",[_arrayDatas[indexPath.row] objectForKey:@"oid"]];
    NSLog(@" - - id  - %@",shujiV.strIDJieShou);
    [self.navigationController pushViewController:shujiV animated:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - Segmented
- (IBAction)mySegment:(UISegmentedControl *)sender {
    NSLog(@"%d",sender.selectedSegmentIndex);
}


#pragma mark - 数据请求(Json-Post)
-(void)goLine{
    NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
    [dic setObject:_strIDJieShou forKey:@"hid"];
    [self getInformationByURl:@"http://www.xdoc.cn/json/LoadOliveInfo.aspx?"andDictionary:dic];
}
-(void)getInformationByURl:(NSString *)url andDictionary:(NSDictionary *)yourDictionary{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain",@"text/html",nil];
    [manager GET:url parameters:yourDictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self initWithDataS:responseObject];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error);
    }];
}
//数据处理
-(void)initWithDataS:(NSDictionary *)theDic{
    NSLog(@" - - - 分类all = %@",theDic);
    _arrayDatas=[[NSMutableArray alloc] initWithArray:[theDic objectForKey:@"ois"]];
    [_myTableV reloadData];
}


@end
